<template>

  <div id="client">
    <div class="client-top" style="">
      供应商：
<<<<<<< HEAD
      <el-input style="width: 150px;margin-left: 0px;margin-right: 20px;" placeholder="请输入供应商编号"
        v-model="payForm.providerName" clearable>
      </el-input>

      <el-button slot="reference" style="margin-left:-20px;margin-right:10px" @click="dialogShow = true">...</el-button>
      <el-dialog top="20px" title="选择供应商" :visible.sync="dialogShow">
        <el-dialog top="20px" title="选择供应商" :visible.sync="dialogShow">
          <ProviderChoose ref="choosePro" :dialogShow="dialogShow" />
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogShow = false">取 消</el-button>
            <el-button type="primary" @click="yes">确 定</el-button>
          </div>
        </el-dialog>
=======
      <el-input style="width: 200px;margin-left: 10px;margin-right: 20px;" placeholder="请输入客户编号" v-model="input"
        clearable>
      </el-input>

      <el-button slot="reference" style="margin-left:-20px;margin-right:10px"
        @click="dialogFormVisible = true">...</el-button>
      <el-dialog top="20px" title="新增客户" :visible.sync="dialogFormVisible">
        <el-select v-model="value" placeholder="类别">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
        <el-input v-model="input" placeholder="请输入内容" style="width: 200px;margin-left: 20px;"></el-input>
        <el-checkbox v-model="checked" style="margin-left: 20px">显示禁用客户</el-checkbox>
        <el-button type="primary" style="margin-left: 20px">查询</el-button>
        <el-table :data="gridData">

          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column width="100" property="name" label="类别"></el-table-column>
          <el-table-column width="100" property="address" label="编号"></el-table-column>
          <el-table-column width="300" property="address" label="名称"></el-table-column>
          <el-table-column width="100" property="address" label="联系人"></el-table-column>
          <el-table-column width="100" property="address" label="手机"></el-table-column>
          <el-table-column width="100" property="address" label="备注"></el-table-column>
        </el-table>
        <div class="block">
          <span class="demonstration"></span>
          <el-pagination layout="prev, pager, next" :total="1000">
          </el-pagination>
        </div>
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
        </div>
      </el-dialog>
      总欠款：
<<<<<<< HEAD
      <el-input style="width: 80px;margin-left: 10px;margin-right: 20px;" placeholder="" clearable disabled>
=======
      <el-input style="width: 80px;margin-left: 10px;margin-right: 20px;" placeholder="" v-model="input" clearable
        disabled>
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
      </el-input>
      付款人：
      <el-select v-model="value" placeholder="付款人" style="width: 100px;">
        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
        </el-option>
      </el-select>


      <span class="demonstration" style="margin-left: 20px;">单据日期:</span>
<<<<<<< HEAD
      <el-date-picker v-model="selectedDate" align="right" type="date" placeholder="选择日期"
        :picker-options="pickerOptions" @change="handleDateChange" style="margin-left: 10px;"></el-date-picker>
      <i class="el-icon-paperclip" style="color: blue;margin-left: 40px"></i>
      <sapn style="color: blue;">上传附件</sapn>
      <span style="margin-left: 10px;">单据编号:</span>
      <el-input style="width: 120px;margin-left: 10px;margin-right: 20px;" placeholder="" clearable>
=======
      <el-date-picker v-model="value2" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions">
      </el-date-picker>
      <i class="el-icon-paperclip" style="color: blue;margin-left: 40px"></i>
      <sapn style="color: blue;">上传附件</sapn>
      <span style="margin-left: 10px;">单据编号:</span>
      <el-input style="width: 120px;margin-left: 10px;margin-right: 20px;" placeholder="" v-model="input" clearable>
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
      </el-input>
      <el-dropdown>
        <span class="el-dropdown-link">
          <i class="el-icon-edit"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>SKDYYYYMMDD</el-dropdown-item>
          <el-dropdown-item>狮子头</el-dropdown-item>
          <el-dropdown-item>螺蛳粉</el-dropdown-item>
          <el-dropdown-item disabled>双皮奶</el-dropdown-item>
          <el-dropdown-item divided>蚵仔煎</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <hr style="margin-top: 10px">
    <div style="margin-top: 10px;float: right">
<<<<<<< HEAD
      <el-button @click="add()">保存</el-button><el-button type="success">审核</el-button><el-button
=======
      <el-button>保存</el-button><el-button type="success">审核</el-button><el-button
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
        type="warning">反审核</el-button><el-button type="primary">提交</el-button>
    </div>
    <div style="clear: both;"></div>
    <div class="client-content" style="margin-top: 10px;">

      <el-table height="180px" :data="tableData" border style="width: 100%;font-size: 13px;">
        <el-table-column fixed prop="" label="" width="50">
<<<<<<< HEAD
          <i class="el-icon-circle-plus-outline" style="margin-left: 8px;" @click="addRow()"></i>
          <br>
          <i class="el-icon-remove-outline" style="margin-left: 8px;"></i>
        </el-table-column>
        <el-table-column fixed prop="account" label="结算账户" width="150">
          <template slot-scope="scope">
            <el-select v-model="scope.row.account" placeholder="结算账户" style="width: 100px;">
              <el-option v-for="item in accounts" :key="item.accountId" :label="item.accountName"
                :value="item.accountId">
              </el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column prop="money" label="付款金额" width="140">
          <template slot-scope="scope">
            <el-input v-model="scope.row.money" style="width: 100px;margin-left: 10px;margin-right: 20px;"
              placeholder="付款金额" clearable @input="checkNum()">
            </el-input>
          </template>
        </el-table-column>
        <el-table-column prop="clearMethod" label="结算方式" width="140">
          <template slot-scope="scope">
            <el-select v-model="scope.row.clearMethod" placeholder="结算方式" style="width: 110px;">
              <el-option v-for="item in clearMethods" :key="item.clearId" :label="item.clearName" :value="item.clearId">
              </el-option>
            </el-select>
          </template>
        </el-table-column>

        <el-table-column prop="remark" label="备注" width="300">
          <template slot-scope="scope">
            <el-input v-model="scope.row.remark" style="width: 250px;margin-left: 10px;margin-right: 20px;"
              placeholder="备注" clearable>
            </el-input>
          </template>
=======
        </el-table-column>
        <el-table-column fixed prop="date" label="结算账户" width="150">
          <el-select v-model="value" placeholder="结算账户" style="width: 100px;">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-table-column>
        <el-table-column prop="name" label="付款金额" width="140">
          <el-input style="width: 100px;margin-left: 10px;margin-right: 20px;" placeholder="收款金额" v-model="input"
            clearable>
          </el-input>
        </el-table-column>
        <el-table-column prop="province" label="结算方式" width="140">
          <el-select v-model="value" placeholder="结算方式" style="width: 110px;">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-table-column>
        <el-table-column prop="city" label="结算号" width="140">
          <el-input style="width: 100px;margin-left: 10px;margin-right: 20px;" placeholder="结算号" v-model="input"
            clearable>
          </el-input>
        </el-table-column>
        <el-table-column prop="address" label="备注" width="300">
          <el-input style="width: 250px;margin-left: 10px;margin-right: 20px;" placeholder="备注" v-model="input"
            clearable>
          </el-input>
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
        </el-table-column>

      </el-table>
      <div style="width: 100%;background-color: blanchedalmond;height: 30px;">
        <table style="width: 78.7%;height: 30px;">
          <tr>
            <td style="width: 50%;">合计：</td>
            <td style="width: 50%;">123</td>
          </tr>
        </table>
      </div>
      <div style="margin-top: 10px">
        <div style="float:right;"> <el-button @click="choose = true">选择源单</el-button><el-button>自动核销</el-button></div>

        <el-dialog top="20px" title="" :visible.sync="choose">
          <div class="block">
<<<<<<< HEAD
=======
            <span class="demonstration">日期：</span>
            <el-date-picker v-model="value2" type="daterange" align="right" unlink-panels range-separator="至"
              start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" style="width: 200px">
            </el-date-picker>
            备注：
            <el-input style="width: 100px; margin-left: 10px; margin-right: 20px" placeholder="备注" v-model="input"
              clearable>
            </el-input>
            客户地址:
            <el-input style="width: 120px; margin-left: 10px; margin-right: 20px" placeholder="客户地址" v-model="input"
              clearable>
            </el-input>
            <el-button type="primary" style="margin-left: 20px">查询</el-button>
          </div>
          <div>源单编号：
            <el-input style="width: 400px; margin-left: 10px; margin-right: 20px" placeholder="源单编号：" v-model="input"
              clearable>
            </el-input>
            业务员：
            <el-select v-model="value" placeholder="业务员：" style="width: 150px;">
              <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </div>
          <el-table :data="gridData">
            <el-table-column type="selection" width="55"> </el-table-column>
            <el-table-column prop="name" label="订单编号" width="120">
            </el-table-column>
            <el-table-column prop="address" label="业务类别" width="120">
            </el-table-column>
            <el-table-column fixed prop="name" label="订单日期" width="150">
            </el-table-column>
            <el-table-column fixed prop="name" label="销售人员" width="150">
            </el-table-column>
            <el-table-column prop="address" label="客户" width="120">
            </el-table-column>
            <el-table-column prop="name" label="订单金额" width="120">
            </el-table-column>
            <el-table-column prop="address" label="已出库核销金额" width="120">
            </el-table-column>
            <el-table-column prop="address" label="未出库核销金额" width="120">
            </el-table-column>
            <el-table-column prop="address" label="审核状态" width="120">
            </el-table-column>
            <el-table-column prop="address" label="交货日期" width="120">
            </el-table-column>
            <el-table-column prop="address" label="关联销货单号" width="120">
            </el-table-column>
            <el-table-column prop="address" label="关联购货单号" width="120">
            </el-table-column>
            <el-table-column prop="address" label="客户地址" width="120">
            </el-table-column>
            <el-table-column prop="address" label="业务员" width="120">
            </el-table-column>
            <el-table-column prop="address" label="备注" width="120">
            </el-table-column>
          </el-table>
          <div class="block">
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
            <span class="demonstration"></span>
            <el-pagination layout="prev, pager, next" :total="1000">
            </el-pagination>
          </div>
          <div slot="footer" class="dialog-footer">
            <el-button @click="choose = false">取 消</el-button>
            <el-button type="primary" @click="choose = false">确 定</el-button>
          </div>
        </el-dialog>
        <el-table height="180px" :data="tableData" border style="width: 100%;font-size: 13px;">
          <el-table-column fixed prop="" label="" width="50">
          </el-table-column>
          <el-table-column fixed prop="date" label="源单编号" width="150">
          </el-table-column>
          <el-table-column prop="name" label="业务类别" width="120">
          </el-table-column>
          <el-table-column prop="province" label="单据日期" width="120">
          </el-table-column>
<<<<<<< HEAD
          <el-table-column prop="city" label="付款到期日" width="120">
=======
          <el-table-column prop="city" label="收款到期日" width="120">
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
          </el-table-column>
          <el-table-column prop="zip" label="已核销金额" width="120">
          </el-table-column>
          <el-table-column prop="city" label="未核销金额" width="120">
          </el-table-column>
          <el-table-column prop="address" label="本次核销金额" width="130">
<<<<<<< HEAD
            <el-input style="width: 130px;margin-left: 10px;margin-right: 20px;" placeholder="本次核销金额" clearable>
=======
            <el-input style="width: 130px;margin-left: 10px;margin-right: 20px;" placeholder="本次核销金额" v-model="input"
              clearable>
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
            </el-input>
          </el-table-column>
          <el-table-column prop="zip" label="单据备注" width="120">
          </el-table-column>
        </el-table>
<<<<<<< HEAD
        <el-input type="textarea" :rows="2" placeholder="暂无备注信息" v-model="payForm.remark"
=======
        <el-input type="textarea" :rows="2" placeholder="暂无备注信息" v-model="textarea"
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
          style="width: 100%;line-height: 20px;">
        </el-input>
        <div style="float:right;margin-right: 20px;margin-top: 10px;">
          本次预付款：
<<<<<<< HEAD
          <el-input style="width: 200px; margin-left: 10px; margin-right: 20px" placeholder="本次预付款：" clearable disabled>
          </el-input>
          <el-button @click="goto('PayHistory')">历史单据</el-button><el-button>操作日志</el-button>
=======
          <el-input style="width: 200px; margin-left: 10px; margin-right: 20px" placeholder="本次预付款：" v-model="input"
            clearable disabled>
          </el-input>
          <el-button>历史单据</el-button><el-button>操作日志</el-button>
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
        </div>
      </div>
      <div>
      </div>
    </div>
    <div style="height: 20px;clear: both;"></div>
  </div>
</template>

<script>
<<<<<<< HEAD
import ProviderChoose from '../public_com/ProviderChoose.vue';
import Top from './Top.vue';

export default {
  components:
  {
    Top,
    ProviderChoose
  },
  data() {
    return {
      selectedDate: "",
      dialogShow: false,
      choose: false,
      dialogFormVisible: false,
      clearMethods: "",
      accounts: "",
      rules: "",
      payForm: {
        aName: "",
        aid: "",
        checkId: "",
        providerCode: "",
        providerName: "",
        providerType: "",
        doId: 1,
        id: "",
        initOrderId: "",
        isWriteOff: 2,
        orderDate: "",
        orderType: 1,
        payAccount: "",
        payoutMoney: "",
        payoutType: "",
        preMoney: "",
        receiveOrderId: "",
        writeoffMoney: "",
        yid: "",
      },
=======
export default {

  data() {
    return {
      choose: false,
      dialogFormVisible: false,
      gridData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }],
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date());
          }
        }, {
          text: '昨天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24);
            picker.$emit('pick', date);
          }
        }, {
          text: '一周前',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', date);
          }
        }]
      },
      tableData: [{
<<<<<<< HEAD
        account: '',
        money: "",
        clearMethod: '',
        clearNum: '',
        remark: '',
      }],
      value1: '',
      value2: '',
    };
  },
  methods: {
    yesForm() {
      this.goodsShow = false
      // this.goodsList = 
      // console.log(this.goodsList)
      //遍历商品列表
      this.inBoundList = this.$refs.chooseGoods.selectionList
    },
    add: function () {
      const reg = /^([1-9]\d*(\.\d{1,2})?|0\.\d{1,2})$/
      if (this.payForm.providerCode === "") {
        alert("请选择供应商")
        return
      }
      if (this.payForm.orderDate === "") {
        alert("请选择日期")
        return
      }
      // if (this.payForm.receiveOrderId === "") {
      //   alert("请选择单据编号不能为空")
      //   return
      // }
      for (const contact of this.tableData) {
        if (contact.account === "") {
          alert("请选择结算账户")
          return
        }
        if (contact.money === "") {
          alert("请填写收款金额")
          return
        }
        if (isNaN(contact.money)) {
          alert("收款金额必须为数字")
          contact.money
          return
        }
        if (!reg.test(contact.money)) {
          alert("收款金额不符合规范")
          return
        }
      }
      console.log(this.tableData)
      console.log(this.payForm)
      // alert(this.payForm.writeoffMoney)
      // return
      const formData = new FormData();
      formData.append('payForm', JSON.stringify(this.payForm))
      formData.append('list', JSON.stringify(this.tableData));
      this.axios.post(
        "/cash/payForm/insert",
        formData,
        {
          headers: {
            'Content-Type': 'application/json'
          }
        }
      ).then(rs => {
        console.log(rs)
        if (rs.data.code === 200) {
          alert("保存成功")
        } else {
          alert("保存失败")
        }
      })
    },
    addRow: function () {
      this.tableData.push({
        account: '',
        money: '',
        clearMethod: '',
        clearNum: '',
        remark: '',
      })
    },
    getClearMethod: function () {
      this.axios({
        url: "/info/clear/selectAll",
      }).then(rs => {

        this.clearMethods = rs.data.list
        console.log(this.clearMethods)
      })
    },
    handleCurrentChange(val) {
      this.getClients(val, 5)
    },

    getEmployees: function () {
      this.axios({
        url: "/info/employee/listAll",
      }).then(rs => {
        console.log(rs)
        this.employees = rs.data.list
      })
    },
    handleDateChange(value) {
      // value 即为选中的日期值
      console.log('选中的日期是：', value);
      this.payForm.orderDate = value
      // 在这里可以执行更多的逻辑，比如更新数据、调用 API 等
    },
    yes() {
      this.dialogShow = false
      var list = this.$refs.choosePro.selectionList
      this.payForm.providerName = list[0].providerName
      this.payForm.providerCode = list[0].providerCode
    },
    getAccounts: function () {
      this.axios({
        url: "/info/account/selectAll",
        params: {

        }
      }).then(rs => {
        console.log(rs)
        this.accounts = rs.data.accounts
      })
    },
    getRules: function () {
      this.axios({
        url: "/info/receipt/selectAll",
      }).then(rs => {
        console.log(rs)
        this.rules = rs.data.list
      })
    },
    goto(to) {
      this.$router.push(to)
    },
  },
  created: function () {
    this.getClearMethod()
    this.getAccounts()
    this.getRules()
=======
        date: '2016-05-02',
        name: '王小虎',
        province: '上海',
        city: '普陀区',
        address: '上海市普陀区金沙江路 1518 弄',
        zip: '200333'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        province: '上海',
        city: '普陀区',
        address: '上海市普陀区金沙江路 1517 弄',
        zip: '200333'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        province: '上海',
        city: '普陀区',
        address: '上海市普陀区金沙江路 1519 弄',
        zip: '200333'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        province: '上海',
        city: '普陀区',
        address: '上海市普陀区金沙江路 1516 弄',
        zip: '200333'
      }],

      value1: '',
      value2: '',
    };
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
  }
}
</script>

<style scoped>
.el-button el-button--default el-popover__reference {
  margin-right: 20px;
}

tr {
  border: 1px solid black;
}
</style>